package edu.ccut.saturn.workflow.agent;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;
import edu.ccut.saturn.operation.Operation;

public class GetExceptionProTreeData extends DefaultComponent{
	public void execute(IParameterContext parameterContext) throws Exception {
		ArrayList<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
		Connection conn = parameterContext.getConnection();
		String sql="select * from wf_process_define where state!=0";
		ArrayList<SaturnData> proList = Operation.dataBase().queryBySQL("http://edu.ccut.saturn.workflow/persistenceModule/data::WF_PROCESS_DEFINE",
				sql, conn);
		if(proList!=null){
			for(SaturnData pro:proList){
				Map<String,Object> map = new HashMap<String,Object>();
				map.put("id", pro.get("process_define_id"));
				map.put("text", pro.getString("process_xml_key"));
				map.put("leaf", true);
				dataList.add(map);
			}
		}
		parameterContext.setParameter(0, dataList);
	}

}
